package com.yuanlrc.base.dao.admin;

import com.yuanlrc.base.entity.admin.Book;
import com.yuanlrc.base.entity.admin.BookCategory;
import com.yuanlrc.base.entity.admin.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface BookDao extends JpaRepository<Book,Long> {
    // 根据图书编号查找
    @Query("select b from Book b where b.id = :id")
    Book  find(@Param("id") Long id);

    @Query("select bc from BookCategory bc where bc.parent.id is null")
    List<BookCategory> findParent();

    @Query("select bc from BookCategory bc where bc.parent.id = :id")
    List<BookCategory> findCategoryByParentId(@Param("id") Long id);

    public Book findByBookName(String bookName);
}
